import { Injectable } from '@angular/core';
import { HttpClient} from '@angular/common/http';
import { Observable, of, Subscription } from 'rxjs';
import { Student, StudentsData } from './student';
import { Course } from "./Course";
import { SelectCourse, SelectCourseData } from "./SelectCourse";

@Injectable({
  providedIn: 'root'
})
export class StudentService {
  constructor(
    private http: HttpClient,
  ) {
  }

  /**
   * 获取所有学生学生信息
   * @param params
   */
  getStudents(params?: { [key: string]: string }): Observable<StudentsData> {
    return this.http.get<StudentsData>('/api/stubasicinfo', {params});
    // return of(STUDENTS);
  }

  getCourses(params?: { [key: string]: string }): Observable<Course[]> {
    return this.http.get<Course[]>('/api/courseinfo', {params});
  }

  /**
   * 获取所有学生选课信息(成绩)
   * @param {Object} [params] 接口请求参数
   */
  getSelectcourses(params?: { [key: string]: string }): Observable<SelectCourse[]> {
    return this.http.get<SelectCourse[]>('/api/course_select_info', {params});
  }

  /**
   * 根据课程号获取选课信息
   * @param {Object} params
   */
  getCoursesByCourseid(params: { [key: string]: string }): Observable<SelectCourseData> {
    return this.http.post<SelectCourseData>('/api/get_course_select_info_byCourseid', params);
  }

  // login(): Observable<Account[]> {
    // return this.http;
  // }

}

